﻿namespace YmtAuth.Web.Service
{
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Net;
    using System.Web;
    using YmtSystem.CrossCutting;

    internal static class HttpServiceAssert
    {
        public static void AssertRequest<TRequest>(this TRequest request
            , Func<bool> condition
            , bool falseThrowOut = false
            , HttpStatusCode? responseCode = null
            , string msg = null
            , string errorCode = null
            , bool writeLog = true)
        {
            var verify = condition();
            if (writeLog)
            {
                var requesVal = ServiceStack.Text.JsonSerializer.SerializeToString(request);
                YmatouLoggingService.Debug("接到客户端请求 {0} {1}", msg, requesVal);
            }
            //TODO:这里完成错误信息输出
            //HttpContext.Current.Response.
        }

        public static void AssertRequest<TRequest>(this TRequest request, Func<bool> condition
             , bool falseThrowOut = false, Action action = null, bool writeLog = true, string msg = "")
        {
            if (writeLog)
            {
                var requesVal = ServiceStack.Text.JsonSerializer.SerializeToString(request);
                YmatouLoggingService.Debug("接到客户端请求 {0} {1}", msg, requesVal);
            }
        }
    }
}